package twocolorballs;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int[] lucknumsred = createlucknumersred();
        int lucknumsblue = random.nextInt(16)+1;//1-16  (0-15)+1
        int[] usernumbersred = new int[6];
        int usernumberblue = 0;
        System.out.println("请输入你的红色球号码(1-33不重复)");
        for(int i=0;i<6;i++)
        {
            usernumbersred[i] = scanner.nextInt();
        }
        System.out.println("请输入你的蓝色球号码(1-16)");
        usernumberblue = scanner.nextInt();
        System.out.println("中奖红球号码是:");
        System.out.println(Arrays.toString(lucknumsred));
        System.out.println("你的红色球号码是:");
        System.out.println(Arrays.toString(usernumbersred));
        System.out.println("中奖篮球号码是:");
        System.out.println(lucknumsblue);
        System.out.println("你的篮球号码是:");
        System.out.println(usernumberblue);
        int judges = judge(lucknumsred,lucknumsblue,usernumbersred,usernumberblue);
        switch (judges)
        {
            case 0:{
                System.out.println("很抱歉，没有中奖");
                break;
            }
            case 1:{
                System.out.println("恭喜你，获得一等奖");
                break;
            }
            case 2:{
                System.out.println("恭喜你，获得二等奖");
                break;
            }
            case 3:{
                System.out.println("恭喜你，获得三等奖");
                break;
            }
            case 4:{
                System.out.println("恭喜你，获得四等奖");
                break;
            }
            case 5:{
                System.out.println("恭喜你，获得五等奖");
                break;
            }
            case 6:{
                System.out.println("恭喜你，获得六等奖");
                break;
            }
        }
    }
    public static int[] createlucknumersred(){
        Random random = new Random();
        int [] arr =  new int[6];
        Arrays.fill(arr,0);
        int i=0;
        while(i<arr.length)
        {
            int num = random.nextInt(33)+1;
            if(num==arr[0]||num==arr[1]||num==arr[2]||num==arr[3]||num==arr[4]||num==arr[5])
            {
                continue;
            }
            else
            {
                arr[i] = num;
                i++;
            }
        }
        return arr;
    }
    public static int judge(int[] lr,int lb,int[] ur,int ub){
        int count = 0;
        for(int i=0;i<ur.length;i++)
        {
            for(int j=0;j<lr.length;j++)
            {
                if(ur[i]==lr[j])
                {
                    count++;
                    break;
                }
            }
        }//查看红色球相同数量
        switch (count)
        {
            case 0:
            case 1: {
                if(ub==lb){
                    return 6;
                }
                else{
                    return 0;
                }
            }
            case 2:
            case 3:{
                if(lb==ub){
                    return 5;
                }
                else{
                    return 0;
                }
            }
            case 4:{
                if(lb==ub){
                    return 4;
                }
                else{
                    return 5;
                }
            }
            case 5:{
                if(lb==ub){
                    return 3;
                }
                else{
                    return 4;
                }
            }
            case 6:{
                if(ub==lb){
                    return 1;
                }
                else{
                    return 2;
                }
            }
            default:{
                return 0;
            }
        }
    }
}